{extend name="../admin/common/base" /}
{block name="body"}
<form class="layui-form" action="" style="padding-right: 10px;margin-top: 10px;">
    <div class="layui-form-item">
        <label class="layui-form-label">回复关键词</label>
        <div class="layui-input-block">
            <input type="text" name="keyword"    placeholder="请输入关键词" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否开启</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" value="1" checked="checked" lay-skin="switch">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">回复类型</label>
        <div id="replyType" class="layui-input-block">
            <input type="radio"  checked  name="type" value="text" title="回复文本">
            <input type="radio" name="type" value="news" title="回复图文" >
            <input type="radio" name="type" value="addon" title="触发应用">
            <input type="radio" name="type" value="voice" title="回复语音" >
            <input type="radio" name="type" value="image" title="回复图片" >
            <input type="radio" name="type" value="video" title="回复视频">
            <input type="radio" name="type" value="music" title="回复音乐" >
        </div>
    </div>
    <div id="tapNode">
        <div class="layui-tab-content">
            <div class=" reply_text layui-tab-item layui-show"><div class="layui-form-item layui-form-text">
                <label class="layui-form-label">回复内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>

            <div class="reply_news layui-tab-item">

                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">封面图</label>
                    <div class="layui-input-block">
                        {:hook('Upload',['type'=>'image','name'=>'picurl','material'=>true])}
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">图文描述</label>
                    <div class="layui-input-block">
                        <textarea name="news_content" placeholder="请输入图文描述" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">连接地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="link"  placeholder="请输入连接地址如：http://xxxx.com/……" autocomplete="off" class="layui-input">
                    </div>
                </div>

            </div>
            <div class="reply_addon layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">选择应用</label>
                    <div class="layui-input-block">
                        <select name="addons">
                            <option value="">请选择应用</option>
                            {volist name="addons" id="v"}
                            <option value="{$v.addon}">{$v.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
            </div>
            <div class="reply_voice layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">语音名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="voice_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">

                    <label class="layui-form-label">语音</label>
                    <div class="layui-input-block">
                        {:hook('Upload',['type'=>'voice','name'=>'voice','bt_title'=>'上传语音','material'=>true])}
                        <p class="tip_for_p">临时语音只支持amr/mp3格式,大小不超过为2M,长度不超过60秒,永久语音只支持mp3/wma/wav/amr格式,大小不超过为5M,长度不超过60秒</p>
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="voice_staus_type" value="0" title="临时">
                        <input type="radio" name="voice_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_image layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">上传图片</label>
                    <div class="layui-input-block">
                        {:hook('Upload',['type'=>'image','name'=>'reply_image','material'=>true])}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="image_staus_type" value="0" title="临时">
                        <input type="radio" name="image_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_video layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">视频标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="video_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">视频</label>
                    <div class="layui-input-block">
                        {:hook('Upload',['type'=>'video','name'=>'reply_video','bt_title'=>'上传视频','material'=>true])}
                        <p class="tip_for_p">临时视频只支持mp4格式,大小不超过为10M,永久视频只支持rm/rmvb/wmv/avi/mpg/mpeg/mp4格式,大小不超过为20M</p>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述内容</label>
                    <div class="layui-input-block">
                        <textarea name="video_content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="video_staus_type" value="0" title="临时">
                        <input type="radio" name="video_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_music layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">音乐标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="music_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源文件</label>
                    <div class="layui-input-block">
                        {:hook('Upload',['type'=>'media','name'=>'music','bt_title'=>'上传音乐'])}

                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">高品质链接</label>
                    <div class="layui-input-block">
                        <input type="text" name="music_link"  placeholder="请输入链接" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述内容</label>
                    <div class="layui-input-block">
                        <textarea name="music_content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="SBT">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    $(function () {
       // $('input[name="type"]').each(function(){alert(this.value);});var oldClass= 'replay_'+ $("input[name='type']:checked").val();
        $("#replyType").click(function(){
            var class_a='reply_'+ $("input[name='type']:checked").val();
            $('.layui-tab-content div').removeClass('layui-show')
            $('.'+class_a).addClass('layui-show')
        });
    })
    layui.use('form', function(){
        var form = layui.form
        form.on('submit(SBT)', function(data){
            var load = layer.load();
            $.post('',data.field,function (res) {
                if(res.status=='0'){
                    layer.close(load);
                    layer.alert(res.msg);
                }
                if(res.status=='1'){
                    layer.close(load);
                    layer.msg(res.msg,{time:1000},function () {
                        window.location.href=res.url;
                    });
                }
            })
            return false;
        });

    });
</script>
{/block}